package Util;

/**
 * @author attcat
 * ---做一个有趣的程序员
 * @date 2022-10-17 21:42
 * @description 自定义一个链表 车厢类
 */
public class ListNode {
    /***
     * 存储具体元素
     */
    public int val;
    /***
     *存储下一个结点地址(钩子）
     */
    public ListNode next;
    public ListNode() {}
    public ListNode(int val) { this.val = val; }
    public  ListNode(int val, ListNode next) { this.val = val; this.next = next;}


    public int getVal() {
        return val;
    }

    public void setVal(int val) {
        this.val = val;
    }

    public ListNode getNext() {
        return next;
    }

    public void setNext(ListNode next) {
        this.next = next;
    }

    @Override
    public String toString() {
        return "ListNode{" +
                "val=" + val +
                ", next=" + next +
                '}';
    }
}
